home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
turbovis
/
tvg103_s.zip
/
TVGRAPH.IN1
< prev
next >
Wrap
Text File
|
1992-07-29
|
30KB
|
986 lines
(*****************************************************************************)
(* *)
(* TVGRAPH Version 1.0 (C) C.L.Burke. Portions (C) Borland *)
(* *)
(* Display Specific routines *)
(* *)
(* 0. Do_Set_XXXXXX - sets all of the functions into the procedure array *)
(* *)
(* 1. Do_INIT_XXXXXX - should initialise all the specific hardware *)
(* 2. Do_DONE_XXXXXX - should reset all specific hardware *)
(* 3. Do_PixelAddr_XXXXXX *)
(* - in ax=y, bx=x | out AH=unshifted bit mask *)
(* - CL=bits to shift BX = byte offset *)
(* 4. TVGraphCursorOn_XXXXXX *)
(* These 3 routines assume GLOBAL TvGraphCursor *)
(* has Start in H and end in L. GLOBAL TvGraphLoc *)
(* X in L and Y in H *)
(* - Turn Cursor on check TvViziFlag *)
(* 5. TVGraphCursorOff_XXXXXX *)
(* - Turn Cursor off check TvViziFlag *)
(* 6. TVUpdateCursor_XXXXXX *)
(* - Update cursor to current specifications *)
(* 7. Do_GraphMOV_XXXXX- expect same parameters at REP MOVSW to text video *)
(* - CX = Number of words (HI=Attr,LO=Char) to move *)
(* - DS:SI = Source of words *)
(* - ES:DI = Normal TEXT destination *)
(* 8. NewJmp_GraphMOV_XXXXXX *)
(* - Replaces the CheckSnow code in Views unit *)
(* - important that the following structure is kept *)
(* *)
(* asm *)
(* call far ptr Do_GraphMOV_XXXXXX *)
(* mov si,es *)
(* pop ax *)
(* pop cx *)
(* pop di *)
(* pop ds *)
(* pop es *)
(* db 0C3H ( RET NEAR - can't use RET FAR!!! ) *)
(* end; *)
(* 9. procedure Draw_Any_Line_XXXXXX(X1,Y1,X2,Y2,Color:word); assembler; *)
(* Generic draw routine assumes X1<X2 *)
(* *)
(* 10. procedure Draw_Horiz_Line_XXXXXX(X1,X2,Y,Color:word); assembler; *)
(* Horizontal draw routine assumes X1<X2 *)
(* *)
(* 11. procedure Draw_Vert_Line_XXXXXX(X,Y1,Y2,Color:word); assembler; *)
(* Vertical draw routine assumes Y1<Y2 *)
(* *)
(*****************************************************************************)
const (* EGA Specific constants *)
EGAVideoMemory =$A000;
EGASequencer =$03C4;
EGAGraphController =$03CE;
Set_EnableSR =$0001;
UseSR =$0F00;
UseCPUMask =$0000;
Default_EnableSR =Set_EnableSR+UseSR;
Set_RWFunction =$0003;
OverWrite =$0000;
LogicalAND =$0800;
LogicalOR =$1000;
LogicalXOR =$1800;
Default_RWFunction =Set_RWFunction+OverWrite;
Set_WriteMode =$0005;
Read_Mode_0 =$0000;
Read_Mode_1 =$0800;
Write_Mode_0 =$0000;
Write_Mode_1 =$0100;
Write_Mode_2 =$0200;
Write_Mode_3 =$0300;
Default_WriteMode =Set_WriteMode+Read_Mode_1+Write_Mode_0;
Default_ColorPlane =$0007;
Default_Mask =$FF08;
BytesInLoop =10; (* Bytes in the simulated loop *)
NumberOfLoops =16; (* Number of coded loops *)
var (* GLobal to free BP in draw line routines *)
VARSlope:byte; (* 0 = slope < 1 , 1= slope >1 *)
BitShift,ReInitBit,NegBitShift,
CharMapPtr,VARVertIncr,VARIncr1,VARIncr2:word;
Procedure Do_INIT_EGAVGA; assembler;
asm
(* Call once at start of program *)
(* all ega/vga routines should return to this state *)
push ax
push cx
push dx
push es
push si
xor ah,ah
xor ch,ch
mov ax,[GraphWidth]
div [CharWidth]
mul [GraphHeight]
mov [ColorList],ax
mov si,ax
mov ax,[VideoBufferSeg]
mov es,ax
mov dx,EGAGraphController (* Set up Graphics controller *)
mov ax,Default_EnableSR
out dx,ax
mov ax,Set_WriteMode+Read_Mode_1+Write_Mode_2 (* For Color init next *)
out dx,ax
mov ax,Default_RWFunction
out dx,ax
mov ax,Default_Mask
out dx,ax
mov ax,Default_ColorPlane
out dx,ax
mov al,0ffh
mov ch,010h
mov cl,0
(* ES:SI = SCreen , CX=Count, DX=port *)
@L10:
and es:[si],cl
inc si
inc cl
dec ch
jnz @L10
mov ax,Default_WriteMode
out dx,ax
(* Set up 16 colors at EGAScreenSegment:[SI] where SI=max-x max-y *)
pop si
pop es
pop dx
pop cx
pop ax
ret
end;
Procedure Do_DONE_EGAVGA; assembler;
asm
(* Call once at end of program *)
push ax
push dx
mov dx,EGAGraphController (* Set up Graphics controller *)
mov ax,Default_Mask (* Restore CRT registers *)
out dx,ax
mov ax,Set_WriteMode+Read_Mode_0+Write_Mode_0
out dx,ax
mov ax,Set_RWFunction+OverWrite
out dx,ax
mov ax,Default_ColorPlane
mov ah,0Fh
out dx,ax
pop dx
pop ax
ret
end;
procedure Do_PixelAddr_EGAVGA; assembler;
asm
(* in ax=y, bx=x | *)
(* CL=bits to shift BX = byte offset *)
(* BX=Y*80+X/8 = Y*64+Y*16+X/8 = Y SHL 4 + Y SHL 6 + X SHR 3 *)
(* CL=BL and 7 *)
mov ch,bl
and ch,7 (* mask *)
mov cl,3
shr bx,cl (* bx=X/8 *)
inc cl
shl ax,cl (* ax=Y*16 *)
add bx,ax (* bx=Y*16+X/8 *)
shl ax,1
shl ax,1 (* ax=Y*64 *)
add bx,ax (* bx=Y*64+Y*16+X/8 *)
mov cl,ch
end;
procedure Do_Cursor_EGAVGA; assembler;
asm
(* Expect CH = start, CL = stop line (0..16), - in TvGraphCursor*)
(* Expect X in DL, Y in DH - character co-ords - in TvGraphPos *)
push cx
push dx
push si
push es
xor [TvViziFlag],0FFh
mov cx,[TvGraphCursor]
mov dx,[TvGraphLoc]
and cx,01F1Fh (* ensure each is 0..31 only *)
cmp cl,ch
jb @SKIP
push cx
mov al,CharHeight
mul dh (* ax:= Y*CharHeight *)
xor dh,dh
mov si,dx (* Si = X *)
xchg ch,cl
xor ch,ch
add ax,cx (* ax:= Y*CharHeight+StartLine *)
mov cx,80
mul cx (* ax:= (Y*CharHeight+StartLine)*80 *)
add ax,dx (* ax:= (Y*CharHeight+StartLine)*80 *)
add si,ax (* si:= (Y*CharHeight+StartLine)*80 + X *)
pop cx
mov al,cl
xor ah,ah
sub al,ch (* al:= (StopLine - StartLine) *)
inc al (* al:= (StopLine - StartLine)+1 *)
mov cx,ax (* use